﻿using DEL.Dzb;
using Microsoft.AspNetCore.Mvc;
using Web.Areas.Gzh.Controllers;
using Web.Models;

// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace Web.Areas.Dzb.Controllers
{
    public class PartyMemberController : DzbController<PartyMember>
    {
        protected override void SetCurrentEntityService()
        {
            CurrentEntityService = BLLFactory.SetPartyMemberService();
        }

        [HttpGet]
        public IActionResult GetPagedListByPartyId(int partyId, int? pageindex = 1)
        {
            int pageIndex = pageindex.Value;
            int rowCount = 0, pageCount = 0;
            if (partyId == 13)
            {
                var data = CurrentEntityService.GetPagedEntitysByLambdaAndSort(pageIndex, PageSize, out rowCount, out pageCount, o => o.Id > 0, OrderLambda, IsASC);
                return Json(new
                {
                    rowCount = rowCount,
                    pageCount = pageCount,
                    rows = data
                });
            }
            else
            {
                var data = CurrentEntityService.GetPagedEntitysByLambdaAndSort(pageIndex, PageSize, out rowCount, out pageCount, o => o.PartyId == partyId, OrderLambda, IsASC);
                return Json(new
                {
                    rowCount = rowCount,
                    pageCount = pageCount,
                    rows = data
                });
            }
        }


    }
}
